package validator

import "regexp"

// 正则常量
const (
	// 定义标签名称
	tagName string = "valid"
	// valid对应的类型
	OptionType   string = "optional" // 可选
	CommentType  string = "comment"  // 描述
	ConfirmType  string = "confirm" // 值比较
	//
	Int         string = "^(?:[-+]?(?:0|[1-9][0-9]*))$"
	Numeric     string = "^[0-9]+$"
	Float       string = "^(?:[-+]?(?:[0-9]+))?(?:\\.[0-9]*)?(?:[eE][\\+\\-]?(?:[0-9]+))?$"
	Email       string = "^(((([a-zA-Z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])+(\\.([a-zA-Z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])+)*)|((\\x22)((((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])|(\\([\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}]))))*(((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(\\x22)))@((([a-zA-Z]|\\d|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])|(([a-zA-Z]|\\d|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])([a-zA-Z]|\\d|-|\\.|_|~|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])*([a-zA-Z]|\\d|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])))\\.)+(([a-zA-Z]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])|(([a-zA-Z]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])([a-zA-Z]|\\d|-|_|~|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])*([a-zA-Z]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])))\\.?$"
	Alpha       string = "^[a-zA-Z]+$"
	AlphaNum    string = "^[a-zA-Z0-9]+$"
	AlphaDash   string = "^[a-zA-Z0-9-_]+$"
	Base64      string = "^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=|[A-Za-z0-9+\\/]{4})$"
	Mobile      string = "^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$"
	IdCard      string = "^([0-9]{15}|[0-9]{18}|[0-9]{17}x)$"
	Chinese     string = "^[\u4e00-\u9fa5]+$"
	UUID        string = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
	AlphaNormal string = "^[a-zA-Z0-9\u4e00-\u9fa5]+$"
)

var (
	rexInt         = regexp.MustCompile(Int)
	rexEmail       = regexp.MustCompile(Email)
	rexAlpha       = regexp.MustCompile(Alpha)
	rexAlphaNum    = regexp.MustCompile(AlphaNum)
	rexAlphaDash   = regexp.MustCompile(AlphaDash)
	rexAlphaNormal = regexp.MustCompile(AlphaNormal)
	rexNumeric     = regexp.MustCompile(Numeric)
	rexBase64      = regexp.MustCompile(Base64)
	rexMobile      = regexp.MustCompile(Mobile)
	rexFloat       = regexp.MustCompile(Float)
	rexIdCard      = regexp.MustCompile(IdCard)
	rexChinese     = regexp.MustCompile(Chinese)
	rexUuid        = regexp.MustCompile(UUID)
)
